<template>
	<view class="login-view">
		<image src="../../static/yonghu.png" mode="widthFix"></image>
		<button type="primary" @click="login">登录</button>
	</view>
</template>

<script setup>
	import {requestApi} from '@/api/request.js'
	function login(){
		wx.showLoading({title:'登录中'})
		wx.login({
			success:async (res)=>{
				const userData = await requestApi('/wxLogin',
				{
					appid:'wxddf05b2fa7374da7',
					secret:'db412f7aa8142a465c738d684d48016e', //我已了解AppSecret不会明文存储在开发平台上，并且已复制保存好该AppSecret
					code:res.code
				},'POST'
			  )
			  wx.setStorageSync('userInfo', userData.data)
			  //console.log(useData);
			  wx.navigateBack({
			    delta: 1
			  })
			  wx.hideLoading()
			}
		})
		/*
		const res = await requestApi('/wxLogin',
		{
			appid:'wxddf05b2fa7374da7',
			secret:'db412f7aa8142a465c738d684d48016e', //我已了解AppSecret不会明文存储在开发平台上，并且已复制保存好该AppSecret
			code:''
		},'POST'
		)
		*/
	}
</script>

<style>
	page{
			background-image: url('https://qita-1252107261.cos.ap-chengdu.myqcloud.com/motuoche.jpg');
			background-position: center center;
			background-repeat: no-repeat;
			background-size: cover;
			/* background: linear-gradient(to bottom, #b3cffa, #f6f8fe); */
		}
		.login-view{
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 0 80rpx;
			margin-top: 400rpx;
			font-size: 35rpx;
		}
		.login-view image{
			width: 150rpx;
		}
		.login-view button{
			width: 100%;
			margin-top: 100rpx;
		}
</style>